#include "pch.h"
#include "BufferObject.h"

BufferObject::BufferObject()
{
	glGenBuffers(1, &Id);
}

BufferObject::~BufferObject()
{
	glBindBuffer(GetType(), 0);
	glDeleteBuffers(1, &Id);
}

void BufferObject::Bind()
{
	glBindBuffer(GetType(), Id);
}

void BufferObject::Unbind()
{
	glBindBuffer(GetType(), 0);
}

void BufferObject::SetData(const void * data, unsigned int len, GLenum type)
{
	Bind();
	glBufferData(GetType(), len, data, type);
}

void BufferObject::SetSubData(const void * data, unsigned int len, unsigned int index)
{
	glBufferSubData(GetType(), index, len, data);
}
